# Author: Sanmu
# CreatTime: 2024/10/24
# Descriptior: 添加供应商信息
from base_page.base_page import BasePage


class VendorPage(BasePage):

    add_button = ('xpath', '//div[@class="table-operator"]/button[1]')
    by_title = ('id','supplier')
    by_contacts = ('id','contacts')
    by_telephone = ('id','telephone')
    by_phoneNum = ('id','phoneNum')
    save_button = ('xpath','//span[text()="保 存"]/..')

    delete_button = ('xpath','//span[text()="删除"]/..')
    input_box = ('xpath', '//input[@type="checkbox"]')
    ant_button = ('xpath','//span[text()="确 定"]/..')
    def open_url(self,path):
        self.open(path)
        self.wait(2)
    #新增
    def add_vendor(self,title,contacts,telephone,phonenum):
        self.click(*self.add_button)
        self.input(*self.by_title,title)
        self.input(*self.by_contacts,contacts)
        self.input(*self.by_telephone,telephone)
        self.input(*self.by_phoneNum,phonenum)
        self.click(*self.save_button)
        self.wait(2)
    #删除
    def delete_vendor(self):
        self.checkbox(*self.input_box)
        self.click(*self.delete_button)
        # 处理弹窗
        self.wait(2)
        self.click(*self.ant_button)



